package com.qiaoyanqing.ximalaya.discovermodule.discover_activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.qiaoyanqing.ximalaya.R;
import com.qiaoyanqing.ximalaya.discovermodule.discover_adapter.DiscoverResDisHotShareLVadapter;
import com.qiaoyanqing.ximalaya.discovermodule.discover_callback.DiscoverRecommendHotRecommendService;
import com.qiaoyanqing.ximalaya.discovermodule.discover_entity.DiscoverHotShare;
import com.qiaoyanqing.ximalaya.url.Urlconfig;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class DiscoverHotShareActivity extends AppCompatActivity {

    private ListView mListView;
    private DiscoverResDisHotShareLVadapter mLVadapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_discover_hot_share);
        mListView= (ListView) findViewById(R.id.hotlistview);

        initData();


    }

    private void initData() {
        Intent intent=new Intent();
     //   String key = intent.getStringExtra("key");

        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(Urlconfig.DISHOTSHARE)
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        DiscoverRecommendHotRecommendService service=retrofit.create(DiscoverRecommendHotRecommendService.class);
        service.hotshare().enqueue(new Callback<DiscoverHotShare>() {
            @Override
            public void onResponse(Call<DiscoverHotShare> call, Response<DiscoverHotShare> response) {

                mLVadapter=new DiscoverResDisHotShareLVadapter(response.body().getList(),DiscoverHotShareActivity.this);

                mListView.setAdapter(mLVadapter);

            }

            @Override
            public void onFailure(Call<DiscoverHotShare> call, Throwable t) {

            }

        });





    }

    public void backclick(View view) {
        finish();
    }
}
